import React from "react";
import ReactDOM from "react-dom/client";
import { App } from "./App";

// 全局错误处理
window.addEventListener("error", (event) => {
  console.error("全局错误:", event.error);
});

window.addEventListener("unhandledrejection", (event) => {
  console.error("未处理的 Promise  rejection:", event.reason);
});

const rootElement = document.getElementById("root");
if (!rootElement) {
  document.body.innerHTML = `
    <div style="padding: 20px; color: red;">
      错误: 找不到 root 元素
    </div>
  `;
} else {
  ReactDOM.createRoot(rootElement).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);
}


